<?php
error_reporting(0);
include 'check.php';
include_once '../comm/conn.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body topmargin="5" leftmargin="0">
<table width="700" border="0">
<tr>
<td style="padding-left:10px; font-size:20px; color:#990000; font-weight:bold">多多返利系统7.1专用数据库检测修复工具(2011.6.11)</td>
</tr>
<tr>
  <td style="padding-left:20px;"><?php
include_once '../comm/conn.php';
$link = mysql_connect($dbserver, $dbuser, $dbpass);
mysql_query("set names utf8");
mysql_select_db($dbname);
$i=0;$j=0;

echo '<span style="font-weight:bold; color:#ff6600; font-size:12px;">开始检测数据库基础表......</span><br>';
$rs=mysql_query("show tables like '".$BIAOTOU."ad';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."ad<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."article';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."article<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."category';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."category<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."file';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."file<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mall';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mall<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mall_comment';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mall_comment<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mall_order';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mall_order<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."malltype';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."malltype<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."mingxi';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."mingxi<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."msg';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."msg<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."msgset';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."msgset<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."shop';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."shop<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."slides';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."slides<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."taobaoset';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."taobaoset<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."tixian';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."tixian<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."tradelist';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."tradelist<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."user';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."user<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."websetting';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."websetting<br>";$i++;}

$rs=mysql_query("show tables like '".$BIAOTOU."yqlj';");	
if(mysql_num_rows($rs)==0){echo "缺少表".$BIAOTOU."yqlj<br>";$i++;}

if($i==0){echo " 数据表正常！";}

echo '<span style="font-weight:bold; color:#ff6600; font-size:12px;"><br>开始检测数据库基础表表内字段......</span><br>';
$rs=mysql_query("show fields from `".$BIAOTOU."ad`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","content","adtype","addtime");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."ad中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."article`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","cid","title","subtitle","att","pic","source","author","resume","pubdate","content","hits","created_by","created_date","delete_session_id","ontop","hot");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."article中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."category`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","pid","name","description","seq");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."category中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."duoduo2010`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","adminname","adminpass","lastlogintime","lastloginip","loginnum","logintime","loginip");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."duoduo2010中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."file`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","path","size","upload_date");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."file中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mall`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","name","merchant","url","logo","catid","fan","hdfk","zgfp","yfzc","ding","cai","des","js","time","sort","yilink","lm");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mall中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mall_comment`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","mall_name","user_name","service","product","deliver","zf","comment","time");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mall_comment中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mall_order`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","order_time","merchant_id","u_id","ddusername","order_code","item_count","item_price","sales","commission","fxje","bill_yyyymmdd","stat_desc","prod_id","qrsj","product_code","unique_id","lm");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mall_order中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."malltype`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","typename","typecode","sort");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."ad中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."mingxi`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","ddusername","shijian","je","addtime","memo");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."mingxi中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."msg`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","title","content","addtime","see","ddusername","senduser");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."msg中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."msgset`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","msg","type");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."msgset中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."shop`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","nick","uid","cid","consumer_protection","level","score","total_num","good_num","city","state","sid","title","pic_path","created","shop_click_url","type","addtime","hits","tuijian","item_score","service_score","delivery_score","fanxianlv","good");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."shop中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."slides`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("id","pic","url","title","hide","addtime","wz");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."slides中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."taobaoset`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","appKey","appSecret","appkey2","appsecret2","appkey3","appsecret3","appkey4","appsecret4","appkey5","appsecret5","userpid","usernick","seckey");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."taobaoset中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."tixian`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","ddusername","txje","zfb","addtime","addip","txstate","realname","mobile","why");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."tixian中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."tradelist`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","pay_time","item_title","shop_title","num_iid","seller_nick","pay_price","commission_rate","commission","item_num","trade_id","outer_code","qrsj","fxje","checked","ddjt");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."tradelist中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."user`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","ddusername","ddpassword","tbusername","regtime","loginnum","lastlogintime","lasttixian","zfb","email","money","txstate","dengji","tjr","mobile","qq","pass_question","pass_answer","yitixian");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."user中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."websetting`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","fxbl","fxbl2","fxbl3","fxbl4","mallfxbl1","mallfxbl2","mallfxbl3","mallfxbl4","tgbl","webtitle","webdesc","keyword","description","url","surl","email","icp","tongji","qq","webnick","emsg","gonggao","renzheng","tixianje","txxz","zhucesong","zhucesonglevel","liebiao","wjt","morensort","moban","hcopen","hctime","dengji1","dengji2","dengji3","shopcj","shopcj_slevel","shopcj_elevel","pagesize","smtp_host","smtp_user","smtp_pw","smtp_open","fxbname","hotword","webclose","webclosemsg","webtype","cha","apisize","mallzh","mallmm","mallwzbh","uc","apijk","gettime","miyue");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."websetting中缺少字段".$myfield."<br>";$j++;}
}
unset($data);
$rs=mysql_query("show fields from `".$BIAOTOU."yqlj`;");
while($row=mysql_fetch_array($rs)){$data[]=$row['Field'];}
$myarr = array("Id","url","webname","addtime","leibie","pic","wz");
foreach($myarr as $myfield){
	if(!in_array($myfield,$data)){echo "表".$BIAOTOU."yqlj中缺少字段".$myfield."<br>";$j++;}
}

if($j==0){echo "数据表内字段正常！<br><br>";}

mysql_close($link);

if($j+$i!=0){
	echo "<br><input type=\"button\" name=\"Submit\" value=\" 一键修复 \" onclick=\"location.href='repairdb.php'\" />";
}
?></td>
</tr>
<tr>
<td style="padding-left:10px; color:#999999; line-height:25px;"><br><br>如果您的数据库缺少字段，可能是你的数据库被破坏或没有运行升级文件。<br>
1、如果你是升级后出现：说明你没有运行升级文件。<br>
2、如果是平时出现：可能数据库被破坏。<br>
3、如果是恢复数据后出现，可能你的数据库被还原到老版本了。<br>
4、如果无法确定提交论坛寻求帮助。
</td>
</tr>
</table>
</body>
</html>